package domain.regularExpression;

import java.util.Vector;

public class UnaryRegularExpressionOperator extends RegularExpressionOperator {
	
	private UnaryRegularExpressionOperator(String name, RegularExpressionElement ree){
		this._name = name;
		Vector<RegularExpressionElement> subElement = new Vector<RegularExpressionElement>();
		subElement.add(ree);
		this._subElements = subElement;
	}
	
	public static UnaryRegularExpressionOperator asterisk(RegularExpressionElement ree){
		return new UnaryRegularExpressionOperator("asterisk",ree);
	}
	
	public static UnaryRegularExpressionOperator plus(RegularExpressionElement ree){
		return new UnaryRegularExpressionOperator("plus",ree);
	}
	
	public static UnaryRegularExpressionOperator interrogation(RegularExpressionElement ree){
		return new UnaryRegularExpressionOperator("interrogation",ree);
	}
	
	public boolean isAsterisk(){
		return this._name.equals("asterisk");
	}
	
	public boolean isPlus(){
		return this._name.equals("plus");
	}
	
	public boolean isInterrogation(){
		return this._name.equals("interrogation");
	}
	
	public String toString(){
		if(isAsterisk()){
			return this.getSubElements().get(0)+"*";
		}else if(isPlus()){
			return this.getSubElements().get(0)+"+";
		}else if(isInterrogation()){
			return this.getSubElements().get(0)+"?";
		}else{
			return "unkUnaryOp";
		}
			
	}
	
}
